package com.it.travel.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.it.travel.pojo.ProductSku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface ProductSkuMapper extends BaseMapper<ProductSku> {
        @Update("update t_product_sku set stock=stock-1,version=version+1 where product_id=#{productId} and stock>0 and version=#{version}")
    int decreaseStock(@Param("productId") Integer productId,
                      @Param("count") Integer count, @Param("version") Integer version
    );
}
